package com.example.ffmpegsharedstudy

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Environment
import android.util.Log
import android.view.View
import android.view.WindowManager
import android.widget.TextView
import com.example.ffmpegsharedstudy.databinding.ActivityMainBinding
import java.io.File

class MainActivity : AppCompatActivity() {

    private lateinit var wAudioPlayer: WAudioPlayer
    private lateinit var wPlayer: WPlayer
    private lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        window.setFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
        )
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)
        wPlayer = WPlayer()
        wAudioPlayer = WAudioPlayer()
        wPlayer.setSurfaceView(binding.surfaceView)
    }

/*    */
    /**
     * A native method that is implemented by the 'ffmpegsharedstudy' native library,
     * which is packaged with this application.
     *//*
    external fun stringFromJNI(): String

    companion object {
        // Used to load the 'ffmpegsharedstudy' library on application startup.
        init {
            System.loadLibrary("ffmpegsharedstudy")
        }
    }*/

    fun openCLick(view: View) {
        val videoFile = File(Environment.getExternalStorageDirectory(), "yu.mp4")
        wPlayer.start(videoFile.absolutePath)
    }

    fun openMusicCLick(view: View) {
        val file = File(
            Environment.getExternalStorageDirectory(),
            "Last_Stop.mp3"
        )
        val input = file.absolutePath
        val output = File(Environment.getExternalStorageDirectory(), "output.pcm").absolutePath
        Log.e(" 文件路径",input+" "+file.exists()+"   ============       "+output)
        wAudioPlayer.start(input, output)
    }
}